package xm.erzhan.conf.ResourcesConf;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Houses {
    private static Houses housesIns;

    public class HousesItem {
        public int lv;
        public int costFood;
        public int costSteel;
        public int costOil;
        public int costSlime;
        public int product;
        public int costSec;

        public HousesItem(int lv, int costFood, int costSteel, int costOil, int costSlime, int product, int costSec) {
            this.lv = lv;
            this.costFood = costFood;
            this.costSteel = costSteel;
            this.costOil = costOil;
            this.costSlime = costSlime;
            this.product = product;
            this.costSec = costSec;
        }
    }

    public List<HousesItem> housesItems = new ArrayList<HousesItem>();

    public HousesItem getConfByLv(int lv) {
        HousesItem housesItem = null;

        Iterator<HousesItem> iterator = this.housesItems.iterator();

        HousesItem item;
        while (iterator.hasNext()) {
            item = iterator.next();
            if (item.lv == lv) {
                housesItem = item;
                break;
            }
        }

        return housesItem;
    }

    private void initHousesItems() {
        this.housesItems.add(new HousesItem(1, 100, 1000, 200, 100, 100, 15));
        this.housesItems.add(new HousesItem(2, 200, 2000, 400, 300, 200, 170));
        this.housesItems.add(new HousesItem(3, 400, 4000, 800, 400, 400, 640));
        this.housesItems.add(new HousesItem(4, 800, 8000, 1600, 800, 800, 1820));
        this.housesItems.add(new HousesItem(5, 1600, 16000, 3200, 1600, 1600, 4800));
        this.housesItems.add(new HousesItem(6, 3200, 32000, 6400, 3200, 3200, 10250));
        this.housesItems.add(new HousesItem(7, 6400, 64000, 12800, 6400, 6400, 14400));
        this.housesItems.add(new HousesItem(8, 12800, 128000, 25600, 12800, 12800, 23450));
        this.housesItems.add(new HousesItem(9, 25600, 256000, 51200, 25600, 25600, 33231));
    }

    public static Houses shared() {
        if (housesIns == null) {
            housesIns = new Houses();
            housesIns.initHousesItems();;
        }

        return housesIns;
    }
}
